package cn.edu.wynu.controller;

import cn.edu.wynu.pojo.Student;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import static org.springframework.web.bind.annotation.RequestMethod.*;

@RestController
public class MyFirstController {

    @RequestMapping("/hello")
    String returnHello() {
        return "hello";
    }

    @RequestMapping(value = "/testPost", method = POST)
    String testRequestMethod() {
        return "hello";
    }

    // http://localhost:8080/testParam?id=1
    @RequestMapping(value = "/testParam", params = "id")
    String testRequestParams(Integer id) {
        System.out.println(String.format("收到了参数id=%d", id));
        return "hello";
    }

    @RequestMapping(value = "/student")
    Student returnStudent() {
        return new Student("zrk", 24, "男");
    }
}
